#include "md_signal.h"
#include <signal.h>
#include <unistd.h>


int md_signal_init(void (*func)(int sig))
{
    int ierro = -1;
    for(int i = 0; i < 100; i++)
    {
        signal(i,SIG_IGN);
    }
    if(NULL == func)
    {
        signal(SIGINT,SIG_DFL);  
        signal(SIGTERM,SIG_DFL);
        signal(SIGSEGV,SIG_DFL);
    }
    else{
        signal(SIGINT,func);  
        signal(SIGTERM,func);
        signal(SIGSEGV,func);
        ierro = 0;
    }
    return ierro;
}